package com.wash.shoes.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 工厂类型枚举
 */
@RequiredArgsConstructor
@Getter
@AllArgsConstructor
public enum FactoryTypeEnum {

    WASH_SHOES("WASH_SHOES_FACTORY", "洗鞋工厂"), WASH_CLOTHES("WASH_CLOTHES_FACTORY", "洗衣工厂"),
    INTEGRATED_FACTORY("INTEGRATED_FACTORY", "综合工厂");

    @EnumValue
    private String code;
    @JsonValue
    private String name;

    @JsonCreator
    public static FactoryTypeEnum getEnumByCode(String code) {
        for (FactoryTypeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取工厂类型
     * 
     * @return
     */
    public static List<Map> getAllFactoryType() {
        List<Map> list = new ArrayList<>();
        for (FactoryTypeEnum value : values()) {
            Map<String, String> map = new HashMap<>();
            map.put("code", value.code);
            map.put("name", value.name);
            list.add(map);
        }
        return list;
    }
}
